<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>绑定QQ - 贫嘴</title>
        <meta name="description" content="贫嘴是一个迷你博客，微博客，心情记录、心情日记、心情随笔、灵感记录、即时新闻，随时随地记录和分享。" />
		<meta name="keywords" content="贫嘴,心情日记,灵感记录,迷你博客,微博客" />

</head>

        <style type="text/css">
* { margin:0; padding:0; }
img { border:0; }

html {
background-color:#97BFD1;
font-size:87.5%;
height:100%;
padding-left:19%;
}
body {
background-color:#FFFFFF;
color:#000000;
font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size:1em;
line-height:1.65;
position:relative;
height:100%;
padding-left:31%;
}

a {
color:#002E6E;
}

address {
margin-bottom:6%;
padding-top:10%;
}
address .fn {
display:none;
}

ul {
list-style-type:none;
}

h1 {
margin-bottom:4%;
}
h1 span {
font-size:2em;
font-style:italic;
margin-right:0.25em;
color:#97BFD1;
vertical-align:middle;
}
h1 span.mark_hash,
h1 span.mark_bang {
margin-left:0.5em;
}

form {
margin-bottom:2%;
width:40em;
}
fieldset {
border:1px solid #ddd;
padding:2em;
-moz-border-radius:0.5em;
-webkit-radius-border:0.5em;
border-radius:0.5em;
}
legend {
font-weight:bold;
}
input {
padding:1em;
margin-left:1em;
}
        </style>

<script src="http://jquery.bassistance.de/validate/lib/jquery.js" type="text/javascript"></script>
<script src="http://jquery.bassistance.de/validate/jquery.validate.js" type="text/javascript"></script>

<script src="http://jquery.bassistance.de/validate/demo/js/cmxforms.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function() {
	// validate the comment form when it is submitted
	$("#form_email-updates").validate();
	
});

</script>
    </head>

    <body class="hentry">
<?php
if (isset($_POST['qq'])&&(!empty($_POST['qq'])) &&isset($_POST['nickname'])&&(!empty($_POST['nickname'])) && isset($_POST['password'])&&(!empty($_POST['password']))) {


	$nickname = addslashes(trim($_POST['nickname']));
	$loginpass = addslashes(trim($_POST['password']));
	$qq = (int)($_POST['qq']);
	if (!$link = mysql_connect('localhost', 'pinzui', 'pinzuihualaoharrie')) {
		echo 'Could not connect to mysql';
		exit;
	}

	if (!mysql_select_db('pinzui', $link)) {
		echo 'Could not select database';
		exit;
	}

	$sql    = "SELECT id,qq,password FROM user WHERE nickname = '$nickname' limit 1";
	$result = mysql_query($sql, $link);

	if (!$result) {
		echo "DB Error, could not query the database\n";
		echo 'MySQL Error: ' . mysql_error();
		exit;
	}

	$data = mysql_fetch_array($result);
	$upass=$data['password'];
	$uid=$data['id'];
	$md5_password = md5($loginpass.$uid);
	if ($upass==$md5_password) {
		//判断是否被其他帐号绑定
		$sql    = "SELECT count(1) as cnt FROM user WHERE qq = '$qq' and id!=$uid";
		$result = mysql_query($sql, $link);
		$vl = mysql_fetch_array($result);
		if($vl['cnt']==0){
			$sql    = "UPDATE `user` SET `qq` = '$qq' WHERE `id` =$uid LIMIT 1 ;";
			$result = mysql_query($sql, $link);
			echo '<script>alert(\'绑定成功!请添加QQ机器人号码：1069480494 为好友，完成绑定。\');</script>';
		}else{
			echo "<script>alert(\"绑定失败! 有可能是以下原因，1. 有可能用户名密码不匹配 2. 每天只限量开放100位 3.QQ号码被其他帐号绑定\");</script>";
		}	
	} else {
		echo "<script>alert(\"绑定失败! 有可能是以下原因，1. 有可能用户名密码不匹配 2. 每天只限量开放100位 3.QQ号码被其他帐号绑定\");</script>";
	}
}
?>
        <address id="site_contact" class="vcard">
            <a class="url home bookmark" href="http://www.pinzui.com">
                “贫嘴” QQ绑定服务内测中，可能会出现不稳定情况，每天限量开放100位。<br>
                1. 提交信息<br>
                2. 添加QQ机器人号码：1069480494 为好友，完成绑定。
                <span class="fn org">pinzui.com</span>
            </a>
        </address>

        <div class="entry-content">
                        <form id="form_email-updates" name="form_email-updates" action="" method="post">
                <fieldset>
                    <legend>“贫嘴” QQ绑定服务内测中</legend>
                    <label for="email">用户名：</label>
                    <input type="text" name="nickname" id="nickname" class="required" title="请输入你的用户名" value="<?php echo $nickname;?>" size="35"><br><br>
                    <label for="nickname" generated="true" class="error" style="display:none;">请输入正确的电子邮件格式</label><br>
                    <label for="email">密&nbsp;&nbsp;&nbsp;码：</label>
                    <input type="password" name="password" id="password" class="required" title="请输入你的密码" value="<?php echo $loginpass;?>" size="35"><br><br>
                     <label for="password" generated="true" class="error" style="display:none;">请输入密码</label><br>
                    <label for="email">QQ号码：</label>
                    <input type="text" name="qq" id="qq" class="required number" title="请输入你的QQ号码" value="<?php echo $qq;?>" size="35"><br><br><label for="qq" generated="true" class="error" style="display:none;">请输入正确的QQ号码</label><br>
                    <input type="submit" name="submit" value="提交">
                    <br>
                   
                    
                </fieldset>

            </form>
                        <p class="more">
                        <a href="http://blog.pinzui.com/">官方博客</a>
                        , <a href="http://www.pinzui.com/">返回首页</a>
                        </p>
        </div>
        <span style="display:none;"><script language="javascript" type="text/javascript" src="http://js.users.51.la/2992516.js"></script>
<noscript><a href="http://www.51.la/?2992516" target="_blank"><img alt="&#x6211;&#x8981;&#x5566;&#x514D;&#x8D39;&#x7EDF;&#x8BA1;" src="http://img.users.51.la/2992516.asp" style="border:none" /></a></noscript></span>
    </body>
</html>
